package com.melon.modules;

import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

@RestController
@RequestMapping("/demo/restful")
public class RestFulController {

    @RequestMapping(value = "/demo01")
    public String demo01(HttpServletRequest request) {
        return "restful";
    }

    /***
     *提供AsyncRestTemplate用于客户端非阻塞异步支持。
     */
    @RequestMapping("/api")
    public Callable<String> api() {
        System.out.println("=====hello");
        return () -> {
            Thread.sleep(10L * 1000); //暂停两秒
            return "服务端";
        };
    }
}
